//
//  KKSingleton.h
//  TTKanKan
//
//  Created by 龚丁禧 on 15/12/2.
//  Copyright © 2015年 xiangchao. All rights reserved.
//

#define singleton_interface(MySingleton)       +(MySingleton *)shareInstance;

#define singleton_implementation(MySingleton)            \
static MySingleton *sharedMySingleton = nil;\
+(MySingleton*)shareInstance {\
    static dispatch_once_t onceToken;\
    if(nil == sharedMySingleton){\
        dispatch_once(&onceToken, ^{\
            sharedMySingleton = [[MySingleton alloc] init];\
        });\
    }\
    return sharedMySingleton;\
}\
\
+(id)allocWithZone:(NSZone *)zone {                             \
static dispatch_once_t onceToken;                             \
dispatch_once(&onceToken, ^{                                 \
if (sharedMySingleton == nil) {                           \
sharedMySingleton = [super allocWithZone:zone];       \
}                                                         \
});                                                           \
return sharedMySingleton;                                     \
}                                                                 \
\
-(id)copyWithZone:(NSZone *)zone {                               \
return self;                                                 \
}                                                                \
\

